﻿#ifndef CMOSSPECTROMETER_H
#define CMOSSPECTROMETER_H
#include <QMutex>
#include "BaseSpectroMeter.h"
#include "avaspec.h"

class CMOSSpectroMeter:public BaseSpectroMeter
{
public:
    CMOSSpectroMeter();
    ~CMOSSpectroMeter();
    // BaseDevice interface
public:
    void SetOtherConfig(QJsonObject config) override;

    // BaseSpectroMeter interface
public:
    bool InitComm();
    static bool EnumSpectro(QList<AvsInfo> &listAvsInfo);
    bool OpenSpectro() override;
    bool CloseSpectro() override;
    bool SetMeasureParam(AvsMeasPara param) override;
    bool GetMeasParam(AvsMeasPara &param) override;
    const QList<double> GetLambda() override;
    bool StartMeasure() override;
    bool Stop() override;

    SpectroInfoTag GetSpectrumInfo() override;
public  slots:
    void ReceiveDataIsHere(int WParam, int LParam);

public slots:
    static void callback(AvsHandle *handle, int *result);

public:
    static QMap<int,CMOSSpectroMeter*> _meterMap;

private:
    int m_hDevice;
    QList<double> _lambda;
    DeviceConfigType *m_psDeviceData = NULL;
    AvsMeasPara _measParam;
    DeviceConfigType *_avsMeasConfig=nullptr;
    void SetMaster(bool isMaster);
    static QMutex  _mutex;   //可以是私有成员变量，也可以是全局变量
};

#endif // CMOSSPECTROMETER_H
